package com.hospital.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

/**
 * 排班实体类
 *
 * @author Hospital Management System
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("tb_schedule")
public class Schedule extends BaseEntity {

    /**
     * 排班ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 医生ID
     */
    @TableField("doctor_id")
    private Long doctorId;

    /**
     * 科室ID
     */
    @TableField("department_id")
    private Long departmentId;

    /**
     * 排班日期
     */
    @TableField("schedule_date")
    private LocalDate scheduleDate;

    /**
     * 排班时段（1-上午，2-下午，3-晚上）
     */
    @TableField("time_slot")
    private Integer timeSlot;

    /**
     * 开始时间
     */
    @TableField("start_time")
    private LocalTime startTime;

    /**
     * 结束时间
     */
    @TableField("end_time")
    private LocalTime endTime;

    /**
     * 挂号费用
     */
    @TableField("registration_fee")
    private BigDecimal registrationFee;

    /**
     * 可预约数量
     */
    @TableField("available_count")
    private Integer availableCount;

    /**
     * 已预约数量
     */
    @TableField("booked_count")
    private Integer bookedCount;

    /**
     * 排班状态（0-停诊，1-正常，2-满号）
     */
    @TableField("status")
    private Integer status;

    /**
     * 备注
     */
    @TableField("remark")
    private String remark;

    /**
     * 医生姓名
     */
    @TableField(exist = false)
    private String doctorName;

    /**
     * 科室名称
     */
    @TableField(exist = false)
    private String departmentName;

    /**
     * 时段名称
     */
    @TableField(exist = false)
    private String timeSlotName;

    /**
     * 获取时段名称
     */
    public String getTimeSlotName() {
        if (timeSlot == null) {
            return null;
        }
        switch (timeSlot) {
            case 1:
                return "上午";
            case 2:
                return "下午";
            case 3:
                return "晚上";
            default:
                return "未知";
        }
    }

    /**
     * 获取状态名称
     */
    public String getStatusName() {
        if (status == null) {
            return null;
        }
        switch (status) {
            case 0:
                return "停诊";
            case 1:
                return "正常";
            case 2:
                return "满号";
            default:
                return "未知";
        }
    }

    /**
     * 医生职称
     */
    @TableField("doctor_title")
    private String doctorTitle;

    /**
     * 时段字符串
     */
    @TableField("time_slot_str")
    private String timeSlotStr;

    /**
     * 最大配额
     */
    @TableField("max_quota")
    private Integer maxQuota;

    /**
     * 剩余配额
     */
    @TableField("remaining_quota")
    private Integer remainingQuota;

    /**
     * 创建时间
     */
    @TableField("create_time")
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @TableField("update_time")
    private LocalDateTime updateTime;

    /**
     * 删除标志
     */
    @TableField("deleted")
    private Integer deleted;
} 